<template>
    <slot :x="x" :y="y"></slot>

</template>
<script setup>
/**
 *  监听鼠标移动的实时位置
 * **/ 
import { ref, onMounted ,onUnmounted} from 'vue'
const x = ref(0)
const y = ref(0)
function update(event) {
    x.value = event.pageX
    y.value = event.pageY
}
onMounted(() => { window.addEventListener('mousemove', update) })
onUnmounted(() => { window.removeEventListener('mousemove', update) })

</script>
<style lang='scss' scoped></style>